-----------------------------------------------------------------------------
-- @Main: test_tokenizer.adb
--
-- @Project: Programmierkurs (SWT)
-- @Version: 1.0
-- @Created: 2007-08-27
-- @Author:  M. Knau�
--
-- @Environment: Gnat GPL 2007, Windows XP SP2
-- @References:  Ada Tokenizer Library
--
-- @Description:
--   This simple test program reads itself using the Ada Tokenizer Library
--   and prints all tokens found with their value, line and column to the
--   console.
-- @Usage:
--   Simply compile using gnatmake and run the executable.
--
-- @Modifications:
--   +2007-08-27 MK: Initial release
-----------------------------------------------------------------------------
with Ada.Text_Io;
with Ada.Strings.Unbounded;

with Ada_Tokenizer;

-----------------------------------------------------------------------------
-- @Procedure: Test_Tokenizer
-----------------------------------------------------------------------------
procedure Test_Tokenizer is

  use Ada.Text_Io;
  use Ada.Strings.Unbounded;

  -- The file to read using the tokenizer.
  File   : String  := "test_tokenizer.adb";

  -- Flag which signals if the file could be opened and a tokenizer could
  -- be created.
  Success: Boolean := False;

  -- Kind, value, line and column of the last read token.
  Kind  : Ada_Tokenizer.Token_Type;
  Value : Unbounded_String;
  Line  : Positive;
  -- Column: Positive;

begin
  -- Open the tokenizer and iff successfull begin parsing all tokens.
  Ada_Tokenizer.Open_Input (File, Success);
  if (Success = True) then
    -- While there are tokens print them to the console
    while (Ada_Tokenizer.Token_Available = True) loop
      Ada_Tokenizer.Get_Token (Kind, Value, Line); -- , Column);
      Put_Line (Ada_Tokenizer.Token_Type'Image (Kind));
      Put_Line ("  " & To_String (Value));
      Put_Line ("   Line: " & Positive'Image (Line)); -- &
--          ", Column: " & Positive'Image (Column));
    end loop;
  end if;
end Test_Tokenizer;
